package com.xxxx.controller;


import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author Str
 * @Date 2021/9/27 14:34
 * @Description :
 */
//  真实开发中不会使用继承Controller，现在是原理阶段
public class HelloController implements Controller {

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        // ModelAndView 视图和模型
        ModelAndView mv = new ModelAndView();

        // 封装对象，放在ModelAndView中，model
        mv.addObject("msg","HelloSpringMVC");
        // 因为springmvc-servlet.xml中配置有路径信息，可以自动拼接
        mv.setViewName("hello");  // : /WEB-INF/jsp/hello.jsp
        return mv;
    }
}
